<?php

namespace app\admin\model\sum;

use app\admin\model\sum\Common;
use app\admin\model\sum\goods\Goods as GoodsModel;
use app\admin\model\sum\StockOrderExpress as StockOrderExpressModel;
use app\admin\model\sum\store\Store as StoreModel;


class StockOrder extends Common
{
    protected $name = 'sum_stock_order';

    protected $type = [
        'ext' => 'json'
    ];
    // 追加属性
    protected $append = [
        'status_text'
    ];

    // 订单状态
    const STATUS_CLOSED = 'closed';
    const STATUS_CANCEL = 'cancel';
    const STATUS_UNPAID = 'unpaid';
    const STATUS_PAID = 'paid';
    const STATUS_COMPLETED = 'completed';

    public function statusList()
    {
        return [
            'closed' => '交易关闭',
            'cancel' => '已取消',
            'unpaid' => '未支付',
            'pending' => '待定',        // 货到付款未付款状态
            'paid' => '已支付',
            'nosend' => '待发货',
            'noget' => '待收货',
            'completed' => '已完成'
        ];
    }

    public function goods()
    {
        return $this->belongsTo(GoodsModel::class, 'goods_id', 'id')->field('id,title,subtitle,image,stock_price');
    }
    public function store()
    {
        return $this->belongsTo(StoreModel::class, 'store_id', 'id')->field('id,store_name');
    }

    public function express()
    {
        return $this->belongsTo(StockOrderExpressModel::class, 'stock_order_express_id');
    }
}
